$(function () {
    let total = 10
    let data = {
        pagenum: 1,
        pagesize: 5
    }
    let str = [`
    <div class="kr_news_date">
        17 <span>08月</span>
    </div>
    `]

    function loadList() {
        // if (total !== 0 && str.length >= total) {
        //     return layer.msg('没有更多数据了')
        // }
        $.ajax({
            type: 'GET',
            url: 'http://192.168.151.61:8888/api/articles',
            data: data,
            success: function (res) {
                console.log(res)
                if (res.status === 0) {
                    total = res.total

                    res.data.forEach(item => {
                        str += `
                        <div class="item">
                            <h4>
                            <a href="./detail.html?id=${item.id}">${item.title}</a>
                            </h4>
                            <p class="meta">
                            <span>15分钟前 分享至</span>
                            <a href="javascript:;" class="wechat"></a>
                            <a href="javascript:;" class="weibo"></a>
                            </p>
                            <p class="brief">${item.content}</p>
                        </div>
                        `
                    })
                    $('.kr_news_list').append(str)
                }
            }
        })

    }
    loadList()

    $('.kr_more').on('click', function () {
        data.pagenum += 1
        loadList()
    })




})